package com.bestv.search.common.service.impl;

import com.bestv.search.common.dao.ProgramDao;
import com.bestv.search.common.dataSource.DataSourceKey;
import com.bestv.search.common.model.Program;
import com.bestv.search.common.service.ProgramManager;

import java.util.Date;
import java.util.List;

public class ProgramManagerImpl implements ProgramManager {

    private ProgramDao programDao;

    public ProgramDao getProgramDao() {
        return programDao;
    }

    public void setProgramDao(ProgramDao programDao) {
        this.programDao = programDao;
    }

    public Program getProgramById(DataSourceKey key, Long id) {
        return programDao.get(id);
    }

    public List<Program> getProgramByCode(DataSourceKey key, String code) {
        return programDao.getProgramByCode(code);
    }

    public List<Program> getPrograms(DataSourceKey key) {
        return programDao.getAll();
    }

    public void saveProgram(DataSourceKey key, Program program) {
        programDao.save(program);
    }

    public void saveProgramList(DataSourceKey key, List<Program> list) {
        programDao.saveObjectList(list);
    }

    public void saveOrUpdateList(DataSourceKey key, List<Program> list) {
        if (list != null) {
            for (Program p : list) {
                programDao.saveOrUpdate(p);
            }
        }
    }

    public void saveOrUpdate(DataSourceKey key, Program p) {
        programDao.saveOrUpdate(p);
    }

    public List<Program> getNewEngineSeriesByUpdateTime(DataSourceKey key, Date updateTime) {
        return programDao.getNewEngineSeriesByUpdateTime(updateTime);
    }

    public Program getProgramById(DataSourceKey key, long id) {
        return programDao.getProgramById(id);
    }
}
